{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b3de697a-4a2b-403f-b36c-d5c64408f4df",
   "metadata": {},
   "source": [
    "# Data Prerequisites"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a96d1679-1ebd-4e9f-a451-41cfc86b3865",
   "metadata": {},
   "source": [
    "\n",
    "Splink requires that you clean your data and assign unique IDs to rows before linking. \n",
    "\n",
    "This section outlines the additional data cleaning steps needed before loading data into Splink.\n",
    "\n",
    "\n",
    "### Unique IDs\n",
    "\n",
    "- Each input dataset must have a unique ID column, which is unique within the dataset.  By default, Splink assumes this column will be called `unique_id`, but this can be changed with the [`unique_id_column_name`](https://moj-analytical-services.github.io/splink/api_docs/settings_dict_guide.html#unique_id_column_name) key in your Splink settings.  The unique id is essential because it enables Splink to keep track each row correctly. \n",
    "\n",
    "### Conformant input datasets\n",
    "\n",
    "- Input datasets must be conformant, meaning they share the same column names and data formats. For instance, if one dataset has a \"date of birth\" column and another has a \"dob\" column, rename them to match. Ensure data type and number formatting are consistent across both columns. The order of columns in input dataframes is not important.\n",
    "\n",
    "### Cleaning\n",
    "\n",
    "- Ensure data consistency by cleaning your data. This process includes standardizing date formats, matching text case, and handling invalid data. For example, if one dataset uses \"yyyy-mm-dd\" date format and another uses \"mm/dd/yyyy,\" convert them to the same format before using Splink.  Try also to identify and rectify any obvious data entry errors, such as removing values such as 'Mr' or 'Mrs' from a 'first name' column.\n",
    "\n",
    "### Ensure nulls are consistently and correctly represented\n",
    "\n",
    "- Ensure null values (or other 'not known' indicators) are represented as true nulls, not empty strings. Splink treats null values differently from empty strings, so using true nulls guarantees proper matching across datasets."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02c22976-080e-4503-a5e0-153179475dd5",
   "metadata": {},
   "source": [
    "## Further details on data cleaning and standardisation\n",
    "\n",
    "Splink performs optimally with cleaned and standardized data. Here is a non-exhaustive list of suggestions for data cleaning rules to enhance matching accuracy:\n",
    "\n",
    "- Trim leading and trailing whitespace from string values (e.g., \" john smith \" becomes \"john smith\").\n",
    "- Remove special characters from string values (e.g., \"O'Hara\" becomes \"Ohara\").\n",
    "- Standardise date formats as strings in \"yyyy-mm-dd\" format.\n",
    "- Replace abbreviations with full words (e.g., standardize \"St.\" and \"Street\" to \"Street\").\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "splink_demos",
   "language": "python",
   "name": "splink_demos"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
